import sys
import os


def curr(path):
    """取得脚本所在目录的相对位置"""
    exec = sys.argv[0]
    return os.path.join(os.path.dirname(exec), path)


def write_once():
    """一次性写入.
    所有空白也会写入。
    """
    with open(curr("poem-out.txt"), "wt") as fout:
        poem = """There was a young lady named Bright,
Whose speed was far faster than light;
She started one day
In a relative way,
And returned on the previous night.
"""
        fout.write(poem)


def write_once_linix_newline():
    """一次性写入.
    换行自动转为linux换行符。
    """
    with open(curr("poem-out-lf.txt"), "wt", newline="\n") as fout:
        poem = """There was a young lady named Bright,
Whose speed was far faster than light;
She started one day
In a relative way,
And returned on the previous night.
"""
        fout.write(poem)


write_once_linix_newline()
